﻿@namespace MudBlazor
@inherits MudBooleanInput<T>
@typeparam T

<MudInputControl Class="@Classname" Style="@Style" Error="@HasErrors" ErrorText="@GetErrorText()" Required="@Required">
    <InputContent>
        <label class="@LabelClassname" id="@_elementId" @onkeydown="HandleKeyDown" @onclick:stopPropagation="@StopClickPropagation">
            <span tabindex="0" class="@CheckBoxClassname">
                @*note: stopping the click propagation is important here. otherwise checking the checkbox results in click events on its parent (i.e. table row), which is generally not what you would want*@
                <input tabindex="-1" @attributes="UserAttributes" type="checkbox" class="mud-checkbox-input" checked="@BoolValue" @onchange="@OnChange" disabled="@GetDisabledState()" @onclick:preventDefault="@GetReadOnlyState()" />
                <MudIcon Icon="@GetIcon()" Color="HasErrors ? Color.Error : Color.Inherit" Size="@Size" />
            </span>
            @if (!string.IsNullOrEmpty(Label))
            {
                <MudText Color="HasErrors ? Color.Error : Color.Inherit">@Label</MudText>
            }
            @if (ChildContent is not null)
            {
                <MudText Color="HasErrors ? Color.Error : Color.Inherit">
                    @ChildContent
                </MudText>
            }
        </label>
    </InputContent>
</MudInputControl>